#include<stdio.h>
#include <string.h>
#include <unistd.h>
#include "../busMq.h"
#define BUSID 0x789

#define TARGET_ADDR 0x01

void recive_call(BUSMQ_MSG_t* msg,int addr)
{
    printf("addr:%d,recive:%d ,%s\n",addr,msg->datalen,msg->data);
    return ;
}

int main()
{
    BUSMQ_Control_t pp_ctrol_1 = {0};
    BUSMQ_Control_t pp_ctrol_2 = {0};

    BUSMQ_MSG_t  sendmq= {0};
    BUSMQ_CREATE(0x789,&pp_ctrol_1,(BUSMQ_RECIVE_CAMMBACK) recive_call,0x02,0);
    BUSMQ_CREATE(0x789,&pp_ctrol_2,(BUSMQ_RECIVE_CAMMBACK) recive_call,0x03,0);
 
    sleep(1);
    strcpy(sendmq.data,"this is a test camfrom 0x02");
    sendmq.datalen = strlen(sendmq.data);
   
    int count  = 60;
    while(count--)
    {
        BUSMQ_MSG_send(&pp_ctrol_1,&sendmq,0x01);
        sleep(1);
    }
    printf("\n销毁两个节点\n");
    BUSMQ_DESTROY_NODE(&pp_ctrol_1);
    BUSMQ_DESTROY_NODE(&pp_ctrol_2);
}